package number_34;

public class Solution {
    public int[] searchRange(int[] nums, int target) {
        int[] res = {-1, -1};
        int l = 0, r = nums.length - 1;
        while (l <= r) {
            if (nums[l] == target && res[0] == -1) {
                res[0] = l;
            }
            if (nums[r] == target && res[1] == -1) {
                res[1] = r;
            }
            if (res[0] == -1) {
                l++;
            }
            if(res[1] == -1) {
                r--;
            }
            if (res[0] != -1 && res[1] != -1) {
                break;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        new Solution().searchRange(new int[]{5,7,7,8,8,10}, 8);
    }
}
